#include "stdafx.h"
#include "net/HTTPResponseStream.hpp"
#include "net/HTTPClientSession.hpp"

NET_NAMESPACE_BEGIN

CHTTPResponseStreamBuf::CHTTPResponseStreamBuf(std::istream& istr) : m_istr(istr)
{
	m_istr.exceptions(std::ios::badbit);
}

CHTTPResponseStreamBuf::~CHTTPResponseStreamBuf()
{
}

int CHTTPResponseStreamBuf::readFromDevice()
{
	return m_istr.get();
}


CHTTPResponseIOS::CHTTPResponseIOS(std::istream& istr) : m_buf(istr)
{
	
}

CHTTPResponseIOS::~CHTTPResponseIOS()
{
}

CHTTPResponseStreamBuf* CHTTPResponseIOS::rdbuf()
{
	return &m_buf;
}


CHTTPResponseStream::CHTTPResponseStream(std::istream& istr, CHTTPClientSession* pSession)
	: CHTTPResponseIOS(istr),
	std::istream(&m_buf),
	m_pSession(pSession)
{
}

CHTTPResponseStream::~CHTTPResponseStream()
{
	delete m_pSession;
}

NET_NAMESPACE_END
